import { defineStore } from 'pinia'
import { handleDefaultSetting, type TempSave } from './helper'

export const useTempSaveStore = defineStore('temp-save-store', {
  state: (): TempSave => handleDefaultSetting(),
  getters: {},
  actions: {
    saveTempData(key: string, data: any) {
      this.tempSaveList[key] = data
    },
    removeTempData(key: string) {
      delete this.tempSaveList[key]
    }
  },
  persist: {
    enabled: true,
    strategies: [
      {
        storage: sessionStorage
      }
    ]
  }
})
